package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SystemExplain;
import com.ruoyi.system.service.ISystemExplainService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 系统须知Controller
 * 
 * @author DEREK
 * @date 2023-11-06
 */
@RestController
@RequestMapping("/system/systemExplain")
public class SystemExplainController extends BaseController
{
    @Autowired
    private ISystemExplainService systemExplainService;

    /**
     * 查询系统须知列表
     */
    @PreAuthorize("@ss.hasPermi('system:systemExplain:list')")
    @GetMapping("/list")
    public TableDataInfo list(SystemExplain systemExplain)
    {
        startPage();
        List<SystemExplain> list = systemExplainService.selectSystemExplainList(systemExplain);
        return getDataTable(list);
    }

    /**
     * 导出系统须知列表
     */
    @PreAuthorize("@ss.hasPermi('system:systemExplain:export')")
    @Log(title = "系统须知", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SystemExplain systemExplain)
    {
        List<SystemExplain> list = systemExplainService.selectSystemExplainList(systemExplain);
        ExcelUtil<SystemExplain> util = new ExcelUtil<SystemExplain>(SystemExplain.class);
        util.exportExcel(response, list, "系统须知数据");
    }

    /**
     * 获取系统须知详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:systemExplain:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(systemExplainService.selectSystemExplainById(id));
    }

    /**
     * 新增系统须知
     */
    @PreAuthorize("@ss.hasPermi('system:systemExplain:add')")
    @Log(title = "系统须知", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SystemExplain systemExplain)
    {
        return toAjax(systemExplainService.insertSystemExplain(systemExplain));
    }

    /**
     * 修改系统须知
     */
    @PreAuthorize("@ss.hasPermi('system:systemExplain:edit')")
    @Log(title = "系统须知", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SystemExplain systemExplain)
    {
        return toAjax(systemExplainService.updateSystemExplain(systemExplain));
    }

    /**
     * 删除系统须知
     */
    @PreAuthorize("@ss.hasPermi('system:systemExplain:remove')")
    @Log(title = "系统须知", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(systemExplainService.deleteSystemExplainByIds(ids));
    }
}
